package com.sx.springbootshiro.mapper;

import com.sx.springbootshiro.model.LoginUserVB;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface LoginUserMapper {

    @Select("select " +
            " user_id, user_name, user_nickname, user_phone, " +
            " office_number, company_name, user_email, useful " +
            " from login_user " +
            " where useful = 1 ")
    List<LoginUserVB> selectLoginUserVBSByUseful();

    @Select("select " +
            " user_id, user_name, user_nickname, user_password, user_phone, " +
            " office_number, company_name, user_email, useful " +
            " from login_user " +
            " where user_nickname = #{user_nickname} and useful = 1 ")
    LoginUserVB selectLoginUserVBByUserNickname(@Param("user_nickname") String user_nickname);

    @Select("select " +
            " user_id, user_name, user_nickname, user_phone, " +
            " office_number, company_name, user_email, useful " +
            " from login_user " +
            " where user_nickname = #{user_nickname} and user_password = #{user_password} and useful = 1 ")
    LoginUserVB selectLoginUserVBByNicknamePassword(@Param("user_nickname") String user_nickName,
                                                    @Param("user_password") String user_password);

    @Insert("insert into login_user set " +
            " user_name = #{loginUserVB.user_name}, user_nickname = #{loginUserVB.user_nickname}, user_password = #{loginUserVB.user_password},  user_phone = #{loginUserVB.user_phone}, " +
            " company_name = #{loginUserVB.user_phone}")
    boolean insetLoginUserVB(@Param("loginUserVB") LoginUserVB loginUserVB);



}
